package api

import (
	"gift/api/handler"
	"gift/api/middleware"
	"gift/pkg"
	"github.com/gin-gonic/gin"
)

func LoadRouter(r *gin.Engine) {
	r.Use(middleware.Runtime())
	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
			user.Use(jwt.JWTAuth("2210a"))
		}
		live := api.Group("/live")
		{
			live.Use(jwt.JWTAuth("2210a"))
			live.POST("/add", handler.AddLive)
			live.POST("find", handler.FindLive)
			live.POST("/update", handler.UpdateLive)
			live.POST("delete", handler.DeleteLive)
		}
		play := api.Group("/play")
		{
			play.Use(jwt.JWTAuth("2210a"))
			play.POST("/addplay", handler.AddPlay)
			play.POST("findplay", handler.FindPlay)
			play.POST("updateplay", handler.UpdatePlay)
			play.POST("deleteplay", handler.DeletePlay)
		}
		gift := api.Group("/gift")
		{
			gift.Use(jwt.JWTAuth("2210a"))
			gift.POST("/sendgift", handler.Sendgift)
			gift.POST("/finfgift", handler.Finfgift)
			gift.POST("/updategift", handler.Updategift)
			gift.POST("/deletegift", handler.Deletegift)
		}
	}
}
